var _Page;

function _defineProperty(e, a, t) {
    return a in e ? Object.defineProperty(e, a, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[a] = t, e;
}

var R_htmlToWxml = require("../../resource/js/htmlToWxml.js"), imageUtil = require("../../resource/js/images.js"), app = getApp();

Page((_defineProperty(_Page = {
    data: {
        showmsg: !0,
        isuser: !0,
        isphone: !0
    },
    onLoad: function(e) {
        var a = this;
        wx.setNavigationBarTitle({
            title: "会员中心"
        });
        var t = wx.getStorageSync("userInfo");
        if (console.log(t), t) if (t.hasOwnProperty("wxInfo")) {
            a.data.isuser = !0;
            var n = t.memberInfo.uid;
            app.util.request({
                url: "entry/wxapp/Checkusertel",
                data: {
                    uid: n
                },
                success: function(e) {
                    e.data.message.errno || (a.data.isphone = e.data.data.isphone, a.setData({
                        isphone: a.data.isphone,
                        isuser: a.data.isuser,
                        userinfo: t
                    }));
                }
            });
        } else a.data.isuser = !1; else a.data.isuser = !1;
        console.log(a.data.isuser), a.setData({
            isuser: a.data.isuser
        });
    },
    toAgent: function() {
        var e = wx.getStorageSync("userInfo").memberInfo.uid;
        app.util.request({
            url: "entry/wxapp/Checkagent",
            data: {
                uid: e
            },
            success: function(e) {
                if (!e.data.message.errno) if (0 == e.data.data.error) wx.navigateTo({
                    url: "/weixinmao_zp/pages/agentcenter/index"
                }); else {
                    if (1 == e.data.data.error) return void wx.showModal({
                        title: "提示",
                        content: e.data.data.msg,
                        showCancel: !1
                    });
                    wx.navigateTo({
                        url: "/weixinmao_zp/pages/regagent/index"
                    });
                }
            }
        });
    },
    bindGetUserInfo: function(e) {
        var a = this;
        app.util.getUserInfo(function(e) {
            console.log(e), a.data.isuser = !0, a.setData({
                userinfo: e,
                isuser: a.data.isuser
            });
        }, e.detail);
    },
    onReady: function() {},
    tomyAgent: function() {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/myagent/index"
        });
    },
    toOrderlist: function(e) {
        var a = e.currentTarget.dataset.id;
        console.log(a), wx.navigateTo({
            url: "/weixinmao_house/pages/orderlist/index?id=" + a
        });
    },
    toMyPay: function(e) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/order/index"
        });
    },
    toMyNote: function(e) {
        var a = e.currentTarget.dataset.id;
        console.log(a), wx.navigateTo({
            url: "/weixinmao_zp/pages/mynote/index?id=" + a
        });
    },
    toMySave: function(e) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/mysave/index"
        });
    },
    refreshNotice: function(e) {
        var a = wx.getStorageSync("userInfo");
        app.util.request({
            url: "entry/wxapp/refreshNotice",
            data: {
                sessionid: a.sessionid,
                uid: a.memberInfo.uid
            },
            success: function(e) {
                wx.showToast({
                    title: "刷新成功",
                    icon: "success",
                    duration: 2e3,
                    success: function() {}
                });
            }
        });
    },
    toMyFind: function(e) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/myfind/index"
        });
    },
    toMyinvaterecord: function(e) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/myinvaterecord/index"
        });
    },
    toMyNotice: function(e) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/mynotice/index"
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {}
}, "bindGetUserInfo", function(e) {
    var s = this;
    app.util.getUserInfo(function(a) {
        console.log(a), s.data.isuser = !0;
        var e = a.memberInfo.uid, t = a.wxInfo.nickName, n = a.wxInfo.avatarUrl;
        0 < (s.data.uid = e) && (s.setData({
            userinfo: a,
            isphone: !1,
            isuser: s.data.isuser
        }), app.util.request({
            url: "entry/wxapp/Updateuserinfo",
            data: {
                uid: e,
                nickname: t,
                avatarUrl: n
            },
            success: function(e) {
                e.data.message.errno || (s.data.isphone = e.data.data.isphone, s.setData({
                    userinfo: a,
                    isphone: s.data.isphone,
                    isuser: s.data.isuser
                }));
            }
        }));
    }, e.detail);
}), _defineProperty(_Page, "cancelUser", function(e) {
    this.data.isuser = !0, this.setData({
        isuser: this.data.isuser
    });
}), _defineProperty(_Page, "cancelPhone", function(e) {
    this.data.isphone = !0, this.setData({
        isphone: this.data.isphone
    });
}), _defineProperty(_Page, "saveuserinfo", function(e) {
    var a = this, t = e.detail.value.name, n = e.detail.value.tel;
    a.data.showmsg = !0;
    var s = wx.getStorageSync("userInfo");
    "" != t ? "" != n ? app.util.request({
        url: "entry/wxapp/saveuserinfo",
        data: {
            sessionid: s.sessionid,
            uid: s.memberInfo.uid,
            name: t,
            tel: n
        },
        success: function(e) {
            if (0 != e.data.errno) return wx.hideLoading(), void wx.showModal({
                title: "失败",
                content: e.data.msg,
                showCancel: !1
            });
            wx.showToast({
                title: "操作成功",
                icon: "success",
                duration: 2e3
            }), a.setData({
                showmsg: a.data.showmsg
            });
        }
    }) : wx.showModal({
        title: "提示",
        content: "请填写您的手机号",
        showCancel: !1
    }) : wx.showModal({
        title: "提示",
        content: "请填写您的姓名",
        showCancel: !1
    });
}), _defineProperty(_Page, "closemsg", function(e) {
    this.data.showmsg = !0, this.setData({
        showmsg: this.data.showmsg
    });
}), _defineProperty(_Page, "getPhoneNumber", function(e) {
    console.log(e.detail);
    var a = this, t = wx.getStorageSync("userInfo").memberInfo.uid;
    "getPhoneNumber:fail user deny" == e.detail.errMsg ? wx.showModal({
        title: "提示",
        showCancel: !1,
        content: "未授权",
        success: function(e) {}
    }) : (a.setData({
        isphone: !0
    }), app.util.request({
        url: "entry/wxapp/Getphone",
        data: {
            iv: e.detail.iv,
            encryptedData: e.detail.encryptedData,
            uid: t
        },
        success: function(e) {
            e.data.message.errno || a.setData({
                isphone: !0
            });
        }
    }));
}), _defineProperty(_Page, "onReachBottom", function() {}), _defineProperty(_Page, "toMycouponlist", function(e) {
    wx.navigateTo({
        url: "/weixinmao_house/pages/couponlist/index"
    });
}), _defineProperty(_Page, "Puboldhouse", function(e) {
    wx.navigateTo({
        url: "/weixinmao_house/pages/pub/index"
    });
}), _defineProperty(_Page, "onShareAppMessage", function() {}), _defineProperty(_Page, "checkuser", function(a) {
    var t = this, e = (a = a, wx.getStorageSync("userInfo"));
    return e ? e.memberInfo.uid ? void app.util.request({
        url: "entry/wxapp/checkuserinfo",
        data: {
            sessionid: e.sessionid,
            uid: e.memberInfo.uid
        },
        success: function(e) {
            0 == e.data.data.error ? (console.log(a), a.doServices()) : 2 == e.data.data.error && a.doServices();
        }
    }) : (console.log("tmddddsssssqqqqs1111"), app.util.getUserInfo(function(e) {
        t.setData({
            userinfo: e
        });
    }), !1) : (console.log("tmddddssssss222222"), app.util.getUserInfo(function(e) {
        t.setData({
            userinfo: e
        });
    }), !1);
}), _Page));